package per.liu.dao.impl;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import per.liu.dao.EventDao;
import per.liu.hibernate.Event;

/**
 * Created by Administrator on 2015/2/12.
 */
@Repository
public class EventDaoImpl implements EventDao {

	@Autowired
	private SessionFactory sessionFactory;

	private Session getSession() {
		return sessionFactory.openSession();
	}

	@Override public void update(Event event) {
		String hqlVersionedUpdate = "update Event set name = :newName where name = :oldName";
		getSession().createQuery(hqlVersionedUpdate).executeUpdate();
	}

}
